package com.tc.data.spring.validator;

import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Transactional;

/**
 *  @author zhixin02.liu
 */
public class TransactionAnnotationValueValidator implements TransactionAnnotationValidator {

	/**
	 *  Check whether @Transactional's value is blank or not.
	 *  Since this validator will be register to pointcut only that contains more than one TransactionManager.
	 *  So each @Transactional's value should be nonblank.
	 */
	@Override
	public void validateTransactionAnnotation(Transactional transactional, String name) {
		if (StringUtils.isBlank(transactional.value())) {
			throw new RuntimeException(
				"Application have multi transactionManager. " +
				"Method or Class:" + name + " with @Transactional annotation must assign value parameter.");
		}
	}

}
